<?php
if(!defined('IN_WOGU')) {
    exit('Access Denied');
}

Loader::loadUserClass('MemberCookie', true, 'member');

class FrontController extends Controller
{
    protected $_lang = null;
    protected $_member = null;
    protected $_memberinfo = null;
    protected $_inapp = false;
    protected $_rl = null;
    
    protected function _init() {
        App::getInstance()->initDb()->initSession();
        $this->_lang = Loader::loadLang('member', 'member');
        $this->_inapp = get_cookie('appweibo') || get_cookie('apptaobao');
    }
    
    public function getRl() {
        if(!$this->_rl) {
            $this->_rl = Loader::loadUserModel('RlModel', true, 'member');
        }
        
        return $this->_rl;
    }
    
    public function getMember() {
        if(!$this->_member) {
            $this->_member = Loader::loadUserModel('MemberModel', true, 'member');
        }
        
        return $this->_member;
    }
    
    public function getMemberInfo() {
        if(!$this->_memberinfo) {
            $this->_memberinfo = $this->getMember()->getMemberInfo(array('userid' => MemberCookie::userid()));
        }
        
        return $this->_memberinfo;
    }
    
    protected function _t($tpl) {
        return $this->_inapp ? ('app_' . $tpl) : $tpl;
    }
    
    protected function _initFront() {}
}